var t = require;
var e = module;
var o = exports;
var n =
        (this && this.__extends) ||
        (function () {
            var t = function (e, o) {
                return (t =
                    Object.setPrototypeOf ||
                    ({__proto__: []} instanceof Array &&
                        function (t, e) {
                            t.__proto__ = e;
                        }) ||
                    function (t, e) {
                        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                    })(e, o);
            };
            return function (e, o) {
                function n() {
                    this.constructor = e;
                }
                t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
            };
        })(),
    r =
        (this && this.__decorate) ||
        function (t, e, o, n) {
            var r,
                a = arguments.length,
                i = a < 3 ? e : null === n ? (n = Object.getOwnPropertyDescriptor(e, o)) : n;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, o, n);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (r = t[s]) && (i = (a < 3 ? r(i) : a > 3 ? r(e, o, i) : r(e, o)) || i);
            return a > 3 && i && Object.defineProperty(e, o, i), i;
        };
Object.defineProperty(o, "__esModule", {value: !0}), (o.TanchuangHuodong = void 0);
var a = t("BootConst"),
    i = t("Counter"),
    s = t("WatchVideo"),
    c = t("ConfS"),
    l = t("Const"),
    u = t("LoadImgs"),
    p = t("Platforms"),
    f = t("Popup"),
    d = t("Sounds"),
    h = t("TableRules"),
    y = cc._decorator,
    g = y.ccclass,
    v =
        (y.property,
        (function (t) {
            function e() {
                return (null !== t && t.apply(this, arguments)) || this;
            }
            var o;
            return (
                n(e, t),
                (o = e),
                (e.prototype.init = function () {
                    var t = this,
                        e = this.node.getChildByName("container");
                    (this.img = e.getComponent(cc.Sprite)),
                        (this._time = e.getChildByName("time")),
                        (this.time = this._time.getChildByName("txt").getComponent(cc.Label)),
                        (this._action = e.getChildByName("action")),
                        (this.lingqu = this._action.getChildByName("lingqu")),
                        this.lingqu.on(cc.Node.EventType.TOUCH_START, function () {
                            d.Sounds.playFX("点击"),
                                l.default.addMoney(
                                    "金币",
                                    c.DatasManager.弹窗活动奖励1,
                                    "弹窗活动1倍奖励",
                                    t.watchVideo,
                                    null
                                ),
                                l.default.addMoney(
                                    "钻石",
                                    c.DatasManager.弹窗活动奖励2,
                                    "弹窗活动1倍奖励",
                                    t.watchVideo,
                                    null
                                ),
                                (p.default.userStorage.已领取弹窗活动奖励 = !0),
                                p.default.userStorage.setDirty(),
                                t.refresh();
                        }),
                        (this.watchVideo = this._action.getChildByName("watchVideo")),
                        this.watchVideo.on(cc.Node.EventType.TOUCH_END, function () {
                            s.default.show(a.dd.tanchuangHuodong, function () {
                                l.default.addMoney(
                                    "金币",
                                    2 * c.DatasManager.弹窗活动奖励1,
                                    "弹窗活动2倍奖励",
                                    t.watchVideo,
                                    null
                                ),
                                    l.default.addMoney(
                                        "钻石",
                                        2 * c.DatasManager.弹窗活动奖励2,
                                        "弹窗活动2倍奖励",
                                        t.watchVideo,
                                        null
                                    ),
                                    (p.default.userStorage.已领取弹窗活动奖励 = !0),
                                    p.default.userStorage.setDirty(),
                                    t.refresh();
                            });
                        }),
                        (this._yilingqu = this._action.getChildByName("yilingqu")),
                        (this.yilingqu = this._yilingqu.getChildByName("txt").getComponent(cc.Label)),
                        (this.yilingqu.string = c.DatasManager.弹窗活动已领取),
                        (this._end = e.getChildByName("end")),
                        (this.end = this._end.getChildByName("txt").getComponent(cc.Label)),
                        (this.end.string = c.DatasManager.弹窗活动已结束);
                    var n = c.DatasManager.弹窗活动开始时间.match(/(\d+)\D+(\d+)\D+(\d+)\D+(\d+)\D+(\d+)\D+(\d+)/),
                        r = new Date(
                            parseInt(n[1]),
                            parseInt(n[2]) - 1,
                            parseInt(n[3]),
                            parseInt(n[4]),
                            parseInt(n[5]),
                            parseInt(n[6])
                        ),
                        f = new Date();
                    o.startSec = Math.ceil(r.getTime() / 1e3);
                    var h = Math.ceil(f.getTime() / 1e3),
                        y = o.startSec - h;
                    y > 0
                        ? ((this._time.active = !0),
                          (this._action.active = !1),
                          (this._end.active = !1),
                          (this.counter = new i.default()),
                          this.counter.init(y, function (e) {
                              var o = p.default.formatTime(e, !0, !0);
                              (t.time.string = "活动 " + o + " 后开始"),
                                  p.default.弹窗活动按钮 && (p.default.弹窗活动按钮.time.string = o);
                          }),
                          this.counter.start(function () {
                              (t.counter = null),
                                  (t._time.active = !1),
                                  (t._action.active = !0),
                                  p.default.弹窗活动按钮 && (p.default.弹窗活动按钮.shake(), t.autoShow());
                          }),
                          console.log(c.DatasManager.弹窗活动未开始 + " " + c.DatasManager.弹窗活动开始时间))
                        : ((this._time.active = !1), (this._action.active = !0), (this._end.active = !1)),
                        y < 86400 * -c.DatasManager.弹窗活动持续天数 ||
                            u.LoadImgs.load(l.default.url_prefix_share + c.DatasManager.弹窗活动大图, !0, function (e) {
                                t.img.spriteFrame = e;
                            }),
                        (this.close = e.getChildByName("close")),
                        this.close.on(cc.Node.EventType.TOUCH_END, function () {
                            d.Sounds.playFX("点击"), t.hide();
                        });
                }),
                (e.prototype.refresh = function () {
                    p.default.userStorage.已领取弹窗活动奖励
                        ? ((this.lingqu.active = !1),
                          (this.watchVideo.active = !1),
                          (this._yilingqu.active = !0),
                          p.default.弹窗活动按钮 && p.default.弹窗活动按钮.stopShake())
                        : ((this.lingqu.active = !0), (this.watchVideo.active = !0), (this._yilingqu.active = !1));
                }),
                (e.prototype.isEnd = function () {
                    var t = new Date(),
                        e = Math.ceil(t.getTime() / 1e3);
                    return o.startSec - e < 86400 * -c.DatasManager.弹窗活动持续天数;
                }),
                (e.prototype.autoShow = function () {
                    this.showing ||
                        this.isEnd() ||
                        (this._action.active &&
                            (p.default.userStorage.已自动弹出弹窗活动 ||
                                p.default.delays.delay({
                                    time: 1,
                                    action: function () {
                                        p.default.popups.show(o);
                                    }
                                })));
                }),
                (e.prototype.show = function () {
                    t.prototype.show.call(this),
                        h.TableRules.pause(),
                        (p.default.userStorage.已自动弹出弹窗活动 = !0),
                        p.default.userStorage.setDirty(),
                        this.isEnd()
                            ? ((this._time.active = !1),
                              (this._action.active = !1),
                              (this._end.active = !0),
                              p.default.弹窗活动按钮 && p.default.弹窗活动按钮.stopShake())
                            : this.refresh();
                }),
                (e.prototype.showComplete = function () {
                    t.prototype.showComplete.call(this);
                }),
                (e.prototype.hide = function () {
                    t.prototype.hide.call(this);
                }),
                (e.prototype.hideComplete = function () {
                    t.prototype.hideComplete.call(this), h.TableRules.resume();
                }),
                (e = o = r([g], e))
            );
        })(f.Popup));
o.TanchuangHuodong = v;
